#include "Device.h"
#include "System.h"
#include "Config.h"
#include <string.h>

uint8_t MyManuInfo[] = {0x0E, 0x03, 'w', 0, 'c', 0, 'h', 0, '.', 0, 'c', 0, 'n', 0};
uint8_t MyProdInfo[] = {0x28, 0x03, 'U', 0, 'S', 0, 'B', 0, '2', 0, 'I', 0, 'I', 0, 'C', 0,
                              '_', 0, 'C', 0, 'T', 0, 'P', 0, '_', 0, 'C', 0, 'O', 0, 'N', 0, 
                              'T', 0, 'R', 0, 'O', 0, 'L', 0};

uint8_t MyManuInfo_Len;
uint8_t MyProdInfo_Len;

xdata TTouchtPoint GTouchPointData[10]; //按照最大支持的定义
xdata TCtrlTouchPad GCtrlTouchPadInfo;

#ifdef USE_SDCC
uint16_t CTP_VID;           // 可以主函数修改VID PID, 默认为沁恒公司保留VID_PID
uint16_t CTP_PID;
uint8_t MAX_POINT;          // 最大支持点数,如需要支持XP系统,该值最大设置7, 如WIN7或其他系统最大支持10点
uint8_t USB_Enum_OK;        // usb初始化完成会置1。
void USBDeviceInit(void) // usb初始化函数
{
}

uint8_t Absolute_Up_Pack(TTouchtPoint *APTouchPoint, uint16_t PressFlag) // usb上传函数
{
  return 0;
}
#endif

void UsbTouchDeviceInit(uint8_t AMaxPoint) // usb初始化函数
{
  MyManuInfo_Len = sizeof(MyManuInfo);
  MyProdInfo_Len = sizeof(MyProdInfo);

  memset(GTouchPointData, 0, sizeof(GTouchPointData));
  GCtrlTouchPadInfo.XPosMax = 0;
  GCtrlTouchPadInfo.YPosMax = 0;
  GCtrlTouchPadInfo.IrqFlag = 0;
  MAX_POINT = AMaxPoint;
  #if 0
    CTP_VID = 0x2345;
    CTP_PID = 0x6789;
  #endif
  USBDeviceInit();
  irq_enable(true); /* 允许单片机中断 */
  while (UsbEnum == 0); /* 等待USB枚举完成 */
  Uart0Printf("USB Enum OK\r\n");
}